from selenium import webdriver
from selenium.webdriver.common.by import By


class ShopPage():

    def __init__(self, driver):
        # self.driver = webdriver.Chrome()
        self.driver = driver

    search_input_loc = (By.CLASS_NAME, 'search_usercenter_text')
    search_button_loc = (By.CLASS_NAME, 'search_usercenter_btn')
    search_result_loc = (By.XPATH, '//*[@class="search-path fl"]/a[2]')

    def test_search(self, value):
        self.driver.find_element(*self.search_input_loc).send_keys(value)
        self.driver.find_element(*self.search_button_loc).click()

    # 获取搜索结果的文本值
    def get_ele_text(self):
        text = self.driver.find_element(*self.search_result_loc).text
        return text